package org.grew.openEntity.tools;

import org.grew.openEntity.po.system.AlertInfoObj;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: Administrator
 * @Date: 2019/1/9 10:26
 * @Description:
 */
@Component
@Configuration
public class AlertCode {

    private List<AlertInfoObj> alertInfoObjs;

    public AlertCode() {
        alertInfoObjs = new ArrayList<AlertInfoObj>();
        alertInfoObjs.add(new AlertInfoObj(200,"alert-success","提示","保存成功"));
        alertInfoObjs.add(new AlertInfoObj(300,"alert-danger","警告","数据不完整，保存失败"));
        alertInfoObjs.add(new AlertInfoObj(400,"alert-danger","警告","数据重复，保存失败"));
        alertInfoObjs.add(new AlertInfoObj(500,"alert-danger","警告","未知异常，保存失败"));
    }

    public AlertInfoObj getMsgByCode(Integer code){
        for (AlertInfoObj alertInfoObj : alertInfoObjs) {
            if(alertInfoObj.getCode().equals(code)){
                return alertInfoObj;
            }
        }
        return null;
    }

}
